package com.rockcent.api.controller;

import com.rockcent.api.Routes;
import com.rockcent.common.common.JsonResult;
import com.rockcent.common.common.RestDoing;
import com.rockcent.common.controller.BaseController;
import com.rockcent.mall.lib.domain.MallMember;
import com.rockcent.mall.lib.domain.MallMemberRechargeFlow;
import com.rockcent.mall.lib.domain.RockcentFund;
import com.rockcent.mall.lib.dto.UserInfoDto;
import com.rockcent.service.RockcentFundSrv;
import org.apache.commons.collections.map.HashedMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * Created by zhangjh on 2017/3/10.
 */
@RestController
@RequestMapping(value = Routes.API_VERSION)
public class RockcentContoller extends BaseController {

    private final Logger log = LoggerFactory.getLogger(RockcentContoller.class);

    @Autowired
    private RockcentFundSrv rockcentFundSrv;

    /**
     * @api {get} /v1/rockcent/fund/info R 乐宸资金账户信息
     * @apiGroup rockcent
     * @apiVersion 1.0.0
     * @apiHeader {String} userToken 用户token
     * @apiHeader {String} domain    请求域名
     * @apiSuccessExample {json} Success-Response:
     * {
     *   "code": "1",
     *   "desc": "成功",
     *   "data": {
     *     "id": 1,
     *     "dateCreated": "2017-03-10 13:58:31",
     *     "lastUpdated": "2017-03-10 14:02:49",
     *     "version": 1,
     *     "totalAmount": 10000,
     *     "actualRechargeAmount": 10000,
     *     "presentRechargeAmount": 0,
     *     "remark": "收钱了"
     *   }
     * }
     */
    @Transactional
    @RequestMapping(value = Routes.ROCKCENT_FUND_INFO, method = RequestMethod.GET)
    public JsonResult info(HttpServletRequest request) {

        RestDoing doing = jsonResult -> {

            RockcentFund fund = rockcentFundSrv.findOne(1l);

            jsonResult.data = fund;

        };
        return doing.go(request, log);
    }
}
